<?php

/* @var $this yii\web\View */

use yii\helpers\Html;
use yii\web\JsExpression;
use daixianceng\echarts\ECharts;
use app\models\Sale;

$this->title = '出度';
$this->params['breadcrumbs'][] = $this->title;
?>
<style>
    .pagenum{
        width: 50px;
        text-align: center;
    }
    .mysearch{
        width: 60px;
        text-align: center;
    }
</style>
<div class="site-pagerank_search">
<div>
    <?= Html::label('代理人', 'agent', []) ?>
    <?= Html::input('text', 'agent', '', ['id'=>'myagent']) ?>
    <?= Html::Button('查询', ['class' => 'submit','id'=>'chaxun']) ?>
</div>

    <div>
        <div>
            <?= ECharts::widget([
                'responsive' => true,
                'options' => [
                    'style' => 'height: 400%;width: 100%;'
                ],
                'pluginOptions' => [
                    'option' => [
                        'title' => [
                            'text' => '出度'
                        ],
                        'tooltip' => [
                            'trigger' => 'axis'
                        ],
                        'legend' => [
                            'data' => ['出度']
                        ],
                        'grid' => [
                            'left' => '3%',
                            'right' => '4%',
                            'bottom' => '3%',
                            'containLabel' => true
                        ],
                        'toolbox' => [
                            'feature' => [
                                'dataView'=> ['readOnly'=> true],
                                'magicType'=> ['type'=> ['line', 'bar']],
                                'saveAsImage' => []
                            ]
                        ],
                        'xAxis' => [
                            'name' => '日期',
                            'type' => 'category',
                            'boundaryGap' => false,
                            'data' => [],
                        ],
                        'yAxis' => [
                            'type' => 'value'
                        ],
                        'series' => [
                            [
                                'name' => '出度',
                                'type' => 'line',
                                'stack' => '总量',
                                'data' => [],
                            ],
                        ]
                    ]
                ]
            ]); ?>
        </div>
    </div>
</div>

<?php $this->beginBlock('myjs') ?>
function getdata(agent) {
echarts_w0.showLoading();
$.ajax({
url: '<?=\Yii::getAlias('@web')?>/predict/ajaxout?agent='+agent,
type: 'get',
dataType: 'json',
success: function (data)
{
echarts_w0.hideLoading();
echarts_w0.setOption(
{
"xAxis":
{
"name": "日期", "type": "category", "boundaryGap": false,
"data":data.X
},
"yAxis": { "type": "value" },
"series":
[
{ "name": "出度", "type": "line", "stack": "总量",
"data":data.Y
},
]
}
);
}
});
}
$("#chaxun").click(function(){
var agent=$("#myagent").val();
getdata(agent);
});
<?php $this->endBlock() ?>
<?php $this->registerJs($this->blocks['myjs'], \yii\web\View::POS_READY); ?>
<script>

</script>

